<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>字典管理</title>
		<script type="text/javascript" src="../script/common.js"></script>
		<script type="text/javascript">
			//全局变量
			var qt = null;
			var dt = null;
			
			var category = null;
			var categoryName = null;
			
			var dictProp = {};
			
			function load() {
				Eui.showNavigation();
				setPages(["listview","detview"]);
				createTable();
			}
			
			
			//数据处理方法
			function nameFunc(v, r) {//处理数据 点姓名进入查看页面
				return "<a href=# onclick=\"showDictView('" + r[0] + "','" + r[1] + "','" + r[2] + "');return false;\">" + v + "</a>";
			}
			
			
			//显示、刷新表格
			function createTable() {
				var columns = new Array();
				columns[0]={render:nameFunc}
				qt = new QueryTable("dict_list",null,"datalist",columns);
				qt.showTable();
			}
			
			
			/**明细部分**/
			
			//获得字典数据项以供显示
			function showDictView(name, type, editable) {
				dictProp = {name:name,type:type,editable:editable};
				$('dictname').innerHTML = name;
				$('dictcode').innerHTML = type;
				category = type;
				categoryName = name;
				switchPage("detview");
				
				//显示字典数据项
				if (!dt){
					var columns = []
					columns[5]={title:"操作",width:"20%",render:function(v, r) {
						return "<a href=# onclick='editDict(\"" + r[1] + "\")'>修改</a>";
					}}
					dt = new QueryTable("dict_item_list",null,"dictlist",columns);
				}
				dt.paramFunc = function(){
					return {category : category}
				}
				dt.showTable();
			}
			
			//编辑数据字电数据项
			function editDict(code) {
				var url = spellUrl("/basic/edit_dict.html",{
					category : category,
					categoryName : esc(categoryName),
					code : code
				});
				
				openDialogFrame(url,'编辑字典项',200,300,function(){
					showDictView(dictProp.name, dictProp.type, dictProp.editable);
				});
			}
		</script>
	</head>
	<body onload="load()">
		<!--页面导航-->
		<div class="nav">
			<div id="nav">&nbsp;</div>
		</div>
	
		<div id="listview">
			<div id="datalist"></div>
		</div>
		<div id="detview" style="display:none;">
			<div class="form">
				<div class="formTitle">字典明细信息</div>
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable" id="operatortable">
					<tr>
						<td>
							<label>字&nbsp;典&nbsp;名</label>
							<span id="dictname"></span>
						</td>
						<td>
							<label>字典编码</label>
							<span id="dictcode"></span>
						</td>
					</tr>
				</table>
			</div>
			<div id="dictlist"></div>
			<p><button type="button" onclick="switchPage('listview')">返 回</button></p>
		</div>
	</body>
</html>